<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='global-property-'>/**
</span> * @ignore
 * utils about language for html parser
 * @author yiminghe@gmail.com
 */
KISSY.add(&quot;html-parser/utils&quot;, function () {
    return {
        isBooleanAttribute: function (attrName) {
            return (/^(?:checked|disabled|selected|readonly|defer|multiple|nohref|noshape|nowrap|noresize|compact|ismap)$/i).test(attrName);
        },

        collapseWhitespace: function (str) {
            return str.replace(/[\s\xa0]+/g, ' ');
        },

        isLetter: function (ch) {
            return 'a' &lt;= ch &amp;&amp; 'z' &gt;= ch || 'A' &lt;= ch &amp;&amp; 'Z' &gt;= ch;
        },

        /*
         refer: http://www.w3.org/TR/html5/syntax.html#attributes-0
         */
        isValidAttributeNameStartChar: function (ch) {
            return !this.isWhitespace(ch) &amp;&amp;
                ch != '&quot;' &amp;&amp;
                ch != &quot;'&quot; &amp;&amp;
                ch != '&gt;' &amp;&amp;
                ch != &quot;&lt;&quot; &amp;&amp;
                ch != '/' &amp;&amp;
                ch != '=';
        },

        isWhitespace: function (ch) {
            // http://yiminghe.iteye.com/admin/blogs/722786
            // http://yiminghe.iteye.com/admin/blogs/788929
            // 相比平时的空格（&amp;#32;），nbsp拥有不间断（non-breaking）特性。
            // 即连续的nbsp会在同一行内显示。即使有100个连续的nbsp，浏览器也不会把它们拆成两行。
            // &amp;nbsp; =&gt; 160
            // /\s/.test(String.fromCharCode(160))
            // ie return false, others return true
            return /^[\s\xa0]$/.test(ch);
        }
    };
});
/*
 refer:
 -  http://www.w3.org/TR/html5/syntax.html
 */</pre>
</body>
</html>
